<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    //用户输入一个三位数求和
    var num = parseInt(prompt('请输入第一个三位数', '155'));

    var firstNum = num % 10;
    var midNum = parseInt(num / 10) % 10;
    var lastNum = parseInt(num / 100);
    var sum = firstNum + midNum + lastNum;
    alert('您输入的数是' + num + ',他们的和是' + sum);
  </script>
</body>

</html>